import Mock from 'mockjs'
import setupMock, { successResponseWrap, failResponseWrap, } from '@/utils/setup-mock'
setupMock({
  mock: true,
  setup() {
    // 送手机短信验证码
    Mock.mock(new RegExp('/api/third/message/phone-code'), (params) => {
      const { phone } = JSON.parse(params.body)
      if (phone === '18888888888') {
        return successResponseWrap('发送成功')
      }
      return failResponseWrap(null, 500, '发送失败')
    })

    // 手机号登录
    Mock.mock(new RegExp('/api/admin/login/phone'), (params) => {
      const { phone, authCode } = JSON.parse(params.body)
      if (phone === '18888888888' && authCode === '123456') {
        return successResponseWrap({
          token: 'token',
        })
      }
      return failResponseWrap(null, 500, '登录失败')
    })
  },
})